package com.tyl.xtk.service.impl;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.tyl.xtk.service.DataService;
import org.springframework.beans.factory.annotation.Autowired;

import java.io.Serializable;
import java.util.List;

public abstract class DataServiceImpl<M extends BaseMapper<T>, T> implements DataService<T> {

    @Autowired
    protected M baseMapper;

    @Override
    public List<T> selectList() {
        return baseMapper.selectList(null);
    }

    @Override
    public IPage<T> selectPage(IPage<T> page) {
        return baseMapper.selectPage(page, null);
    }

    @Override
    public T selectById(Serializable id) {
        return baseMapper.selectById(id);
    }

    @Override
    public boolean insert(T t) {
        return baseMapper.insert(t) > 0;
    }

    @Override
    public boolean update(T t) {
        return baseMapper.updateById(t) > 0;
    }

    @Override
    public boolean removeById(Serializable id) {
        return baseMapper.deleteById(id) > 0;
    }
}
